//
//  MaterialsTableViewCell.m
//  TenThousand
//
//  Created by 我的 on 16/6/27.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "MaterialsTableViewCell.h"
#import "UIView+SDAutoLayout.h"

@implementation MaterialsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setup];
    }
    return self;
}

- (void)setup
{
    UILabel *titleLabel = [UILabel new];
    titleLabel.textColor = [UIColor grayColor];
    titleLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:titleLabel];
    self.titleLabel = titleLabel;
    titleLabel.text = @"相关材料";
    
    UILabel *contractLabel = [UILabel new];
    contractLabel.textColor = [UIColor grayColor];
    contractLabel.font = [UIFont systemFontOfSize:15.0f];
    [self.contentView addSubview:contractLabel];
    self.contractLabel = contractLabel;
    
    
    UIView *backView = [[UIView alloc] init];
    backView.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:backView];
    self.backView = backView;
    
    
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:lineView];
    self.lineView = lineView;
    
    CGFloat margin = 10;
    
    self.lineView.sd_layout
    .leftSpaceToView(self.contentView, 2* margin)
    .topSpaceToView(self.contentView, 2* margin)
    //    .rightSpaceToView(self.contentView, margin)
    .widthIs(3);
    
      
    self.titleLabel.sd_layout
    .leftSpaceToView(self.lineView, margin)
    .topSpaceToView(self.contentView, 2 *margin)
    .rightSpaceToView(self.contentView, margin)
    .heightIs(20);
   
//    self.contractLabel.sd_layout
//    .centerXEqualToView(self.contentView)
//    .rightEqualToView(self.titleLabel)
//    .topSpaceToView(self.titleLabel, 2 * margin)
//    .autoHeightRatio(20);
    
    
    [_contractLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.contentView);
        make.topMargin.mas_equalTo(self.contentView).offset(50);
        make.height.mas_equalTo(20);
        
    }];
    
    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leftMargin.mas_equalTo(20);
        make.topMargin.mas_equalTo(_contractLabel.mas_bottom).offset(20);
        make.rightMargin.mas_equalTo(-20);
        make.bottomMargin.mas_equalTo(-20);
    }];
   
    
//
//    [self setupAutoHeightWithBottomView:self.contractLabel bottomMargin:margin];
}


- (void)drawRect:(CGRect)rect{
    _backView.layer.cornerRadius = 5;
}

@end
